package prh25.biblioteca.entity.dao.hibernate;

import java.sql.Date;
import java.util.List;

import org.hibernate.criterion.Restrictions;

import prh25.biblioteca.entity.Aluno;
import prh25.biblioteca.entity.dao.AlunoDAO;

/**
 * <p>Hibernate DAO layer for Alunos</p>
 * <p></p>
 *
 * @author Wilson
 * @see http://code.google.com/p/prh-doc/
 */
public class AlunoHibernateDAO extends
		AbstractHibernateDAO<Aluno, Integer> implements
		AlunoDAO {

	/**
	 * Find Aluno by id
	 */
	@SuppressWarnings("unchecked")
	public List<Aluno> findById(Integer id) {
		return findByCriteria(Restrictions.eq("usuario.id", id));
	}
	
	/**
	 * Find Aluno by nome
	 */
	public List<Aluno> findByNome(String nome) {
		return findByCriteria(Restrictions.eq("nome", nome));
	}
	
	/**
	 * Find Aluno by matricula
	 */
	public List<Aluno> findByMatricula(String matricula) {
		return findByCriteria(Restrictions.eq("matricula", matricula));
	}
	
	/**
	 * Find Aluno by email
	 */
	public List<Aluno> findByEmail(String email) {
		return findByCriteria(Restrictions.eq("email", email));
	}
	
	/**
	 * Find Aluno by curso
	 */
	public List<Aluno> findByCurso(String curso) {
		return findByCriteria(Restrictions.eq("curso", curso));
	}
	
	/**
	 * Find Aluno by enderecoId
	 */
	@SuppressWarnings("unchecked")
	public List<Aluno> findByEnderecoId(Integer enderecoId) {
		return findByCriteria(Restrictions.eq("endereco.id", enderecoId));
	}
	
	/**
	 * Find Aluno by projetoPesquisaId
	 */
	@SuppressWarnings("unchecked")
	public List<Aluno> findByProjetoPesquisaId(Integer projetoPesquisaId) {
		return findByCriteria(Restrictions.eq("projetoPesquisa.id", projetoPesquisaId));
	}
	
	/**
	 * Find Aluno by orientadorId
	 */
	@SuppressWarnings("unchecked")
	public List<Aluno> findByOrientadorId(Integer orientadorId) {
		return findByCriteria(Restrictions.eq("orientador.id", orientadorId));
	}

	/**
	 * Find Aluno by dataNascimento
	 */
	public List<Aluno> findByDataNascimento(Date dataNascimento) {
		return findByCriteria(Restrictions.eq("dataNascimento", dataNascimento));
	}
	

}
